package com.ysx.server.mapper;

import com.github.pagehelper.Page;
import com.ysx.server.pojo.dto.CategoryPageQueryDTO;
import com.ysx.server.pojo.entity.Category;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author ysx
* @description 针对表【category(商品分类表)】的数据库操作Mapper
* @createDate 2024-02-15 13:24:22
* @Entity com/ysx/server/pojo.domain.Category
*/
@Mapper
public interface CategoryMapper {
    /**
     * 插入商品类型信息
     * @param category
     * @return
     */
    void save(Category category);

    /**
     * 分页查询
     * @param categoryPageQueryDTO
     * @return
     */
    Page<Category> page(CategoryPageQueryDTO categoryPageQueryDTO);

    /**
     * 更新
     * @param category
     * @return
     */
    boolean update(Category category);

    /**
     * 通过id删除
     * @param id
     * @return
     */
    @Delete("delete from second_hand_trading.category where id=#{id}")
    boolean deleteById(Long id);

    /**
     * 获取商品类型
     * @return
     */
    @Select("select id,categoryName from second_hand_trading.category where categoryStatus=1")
    List<Category> getCategory();

    /**
     * 通过name获取商品类型信息
     * @param id
     * @return
     */
    @Select("select * from second_hand_trading.category where id=#{id}")
    Category getCategoryById(Long id);
}




